<?php

namespace App\Models;

class CtcCancelModel
{
    /**
     * 查询ctc取消次数
     * return Array
     * */
    public static function geCtcCancelInside($conn,$uid,$week){
        $querySql="SELECT `id`,`week`,`uid`,`num`,`state` FROM `ctc_cancel` where `uid` = $uid and `week` = $week order by `id` asc limit 1";
        return $conn->readConn($querySql);
    }
    /**
     * 取消订单
     * return int
     * */
    public static function insetCtcCancel($conn,$CtcCancelExample){
        $insertSql = "insert into `ctc_cancel`(`week`,`uid`)value('$CtcCancelExample->week','$CtcCancelExample->uid')";
        return $conn->executeConn($insertSql);
    }
    /**
     * 编辑ctc取消信息
     * entry $Example
     * return int
     * */
    public static function upCtcCancelInside($conn,$Example){
        $joinSql="";
        if($Example->state !=null){
            $joinSql.=" `state` = '$Example->state',";
        }
        if($Example->end_time !=null){
            $joinSql.=" `end_time` = '$Example->end_time',";
        }
        if($Example->num !=null){
            $joinSql.=" `num` = '$Example->num',";
        }
        if($joinSql !=null){
            $innerJoin = rtrim($joinSql,",");
            $upUserSql = "UPDATE  `ctc_cancel` SET $innerJoin WHERE `id` =$Example->id";
            return $conn->executeConn($upUserSql);
        }
    }
}